{
  //布尔类型
  let b: boolean = true; //声明并赋值
  b = false;
  b = true;
  // b = '中秋快乐'
  let b2: boolean; //声明
  b2 = true; // 赋值

  //数字类型
  let n: number = 521;
  n = 1314;
  n = 258;
  // n = '123';
  n = 0x77; //十六进制
  n = 0o77; // 八进制
  n = 0b1010; //二进制
  console.log(n);

  //字符串类型   单引号  双引号  反引号
  let s: string = "中秋快乐~~";
  s = "123";

  //字面量类型
  let z: "love";
  // z = 123;
  // z = 'like';
  z = "love"; //常量
  let z2: 123 = 123;

  //任意类型  为变量设置了 any 类型, 就丧失了代码提示与错误提醒
  //面向 any 编程
  let a: any;
  a = 100;
  a = "abc";
  a = [1, 2, 3];

  //void 类型  空
  let v: void;
  // v = 100;
  // v = 100;
  // v = null;
  v = undefined;

  function fn(): void {
    return;
  }

  //对象类型
  let o: object;
  o = {};
  o = [];
  o = () => {};
  // o = 123; //不能将类型“number”分配给类型“object”

  //数组类型
  //数字数组
  let arr: number[] = [1, 2, 3, 4, 5];
  let arr2: Array<string> = ["张三", "李四", "王五"];
  arr.push(6);

  //元组
  let arr3: [string, number] = ["干啥呢??", 45];
  let stu: [string, number][] = [
    ["王欣", 18],
    ["刘冉", 18],
    ["笑阳", 10],
  ];

  //枚举类型
  enum Gender {
    Female = "女",
    Male = "男",
    Secret = "保密",
  }

  let me = {
    name: "张三",
    gender: Gender.Male,
  };

  console.log(me);

  //联合类型  //number 限制变量的类型
  let u: number | string | boolean;
  u = 100;
  u = "123";
  u = true;
  // u = [];
  // let arr4: number[] = [1,2,3,4];
  // let res = arr4.find(item => item > 5);
  // console.log(res);

  //类型断言
  let root = document.querySelector("#root") as HTMLElement; //类型断言
  (<HTMLElement>root).style.background = "#aef";

  //类型推导
  let t = 100;
  // t = 'abc';

  let t2;
  t2 = 100;
  t2 = "abc";
  t2 = false;
}
